<?php
$this->pageTitle=Yii::app()->name . ' - '.$model->title; 

$this->breadcrumbs=array(
	'Категории'=>array('index'),
	$model->title,
);

$this->menu=array(
	array('Категории', array('index')),
	array('Нова категория', array('create'),'visible'=>Yii::app()->user->hasAuth(Group::TEACHER)),
	array('Редактиране на категория', array('update', 'id'=>$model->id),'visible'=>Yii::app()->user->hasAuth(Group::TEACHER)),
	array('Управление на категории', array('admin'),'visible'=>Yii::app()->user->hasAuth(Group::MODERATOR)),
);
?>
<br/>
<h1>Категория <?php echo $model->title; ?></h1>
<?php if($model->description){echo '<p>'.$model->description.'</p>';} ?>
<div class="categoryMenu">
<h3>Подкатегории</h3>
<?php


$this->widget('CTreeView', array(
	'data' => Category::getChilds($model->id),
	'animated' => 'fast',	
	'collapsed' => 'true',	
	'persist' => 'cookie',	
	'htmlOptions'=>array('class'=>'treeview-famfamfam')
	));
?>
</div>
<br/><br/>
<div class="postList">

<?php 
	
		$this->widget('zii.widgets.CListView', array(
			'dataProvider'=>$dataProvider,
			'itemView'=>'application.views.post._view',
			'template'=>"{items}\n{pager}",
			'viewData'=>array(
			'list'=>true
			)
		)); 
	if($dataProvider->itemCount === 0){
		echo '<br/><br/><br/>';
		echo '<h2>'.Yii::t('yii','Last').'</h2>';
		$suggestionsProvider = new CActiveDataProvider('Post',array(
			'criteria'=>array(
				'order'=>'id DESC',
				'limit'=>10,
				'condition'=>'status=2 AND language="'.Yii::app()->language.'"',
			),
			'pagination'=>false,
		));
		$this->widget('zii.widgets.CListView', array(
			'dataProvider'=>$suggestionsProvider,
			'itemView'=>'application.views.post._view',
			'template'=>"{items}\n{pager}",
			'viewData'=>array(
			'list'=>true
			)
		)); 
	}
?>


</div>
